package common

type LuacHeader struct {
	MagicCode [4]byte
	Version   byte
	Format    byte
	Endiannes byte
	U1        byte
	U2        byte
	U3        byte
	U4        byte
	U5        byte
}

func (this *LuacHeader) WriteToBuffer(buffer *Buffer) {
	buffer.WriteBytes(this.MagicCode[:])
	buffer.WriteByte(this.Version)
	buffer.WriteByte(this.Format)
	buffer.WriteByte(this.Endiannes)
	buffer.WriteByte(this.U1)
	buffer.WriteByte(this.U2)
	buffer.WriteByte(this.U3)
	buffer.WriteByte(this.U4)
	buffer.WriteByte(this.U5)
}

func NewLuacHeader() *LuacHeader {
	header := new(LuacHeader)
	header.MagicCode[0] = '\033'
	header.MagicCode[1] = 'L'
	header.MagicCode[2] = 'u'
	header.MagicCode[3] = 'a'
	header.Version = 81
	header.Format = 0
	header.Endiannes = 1
	header.U1 = 4
	header.U2 = 8
	header.U3 = 4
	header.U4 = 8
	header.U5 = 0
	return header
}
